#include <logbase.h>

//函数递归

//递归求和
int addfunc(int val)
{
    if(val <= 0)
    {
        return 0;
    }
    else
    {
        return val + addfunc(val - 1);
    }
}

int main(int argc, char **argv)
{
    int tmpsum = addfunc(10);
    logdebugc("%d", tmpsum);
    tmpsum = addfunc(10000);
    logdebugc("%d", tmpsum);
    tmpsum = addfunc(100000);
    logdebugc("%d", tmpsum);
    tmpsum = addfunc(1000000);//崩溃。每个线程栈区8M，超过了就有问题。limit -s查看。
    logdebugc("%d", tmpsum);
    return 1;
}
